package com.burst.reptile.modular.zp.warpper;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.burst.reptile.common.utils.DateUtil;
import com.burst.reptile.common.utils.NumberUtils;
import com.burst.reptile.common.utils.ToolUtil;
import com.burst.reptile.framework.constant.ConstantFactory;
import com.burst.reptile.framework.web.warpper.BaseControllerWrapper;
import com.burst.reptile.modular.zp.entity.ZpResources;
import com.burst.reptile.modular.zp.entity.ZpVote;

public class ZpVoteWrapper extends BaseControllerWrapper<ZpVote> {

    public ZpVoteWrapper(Page<ZpVote> page) {
        super(page);
    }
    
    public ZpVoteWrapper(List<ZpVote> list) {
        super(list);
    }
    
    @Override
    protected void wrapTheMap(ZpVote vote) {
    	Long articleId = vote.getArticleId();
    	ZpResources resources = ConstantFactory.me().getResources(articleId);
    	if(ToolUtil.isNotEmpty(resources)) {
    		vote.setTitle(resources.getTitle());
    		vote.setSummary(resources.getSummary());
    		vote.setCoverImage(resources.getCoverImage());
    		vote.setCoverVideo(resources.getCoverVideo());
    		vote.setReadSize(NumberUtils.amountConversion(resources.getReadSize()));
    		vote.setVoteSize(NumberUtils.amountConversion(resources.getVoteSize()));
    		vote.setUser(ConstantFactory.me().getUser(resources.getUserId()));
    	}
    	vote.setTime(DateUtil.timeToFormat(vote.getCreateTime()));
    }

}
